home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 45
/
Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso
/
Aminet
/
game
/
role
/
ldmud-3.2-bin.lha
/
mud
/
doc
/
LPC
/
initialisation
< prev
next >
Wrap
Text File
|
1999-03-31
|
2KB
|
39 lines
CONCEPT
INITIALIZATION
DESCRIPTION
There are two different flavours of initialisations, selectable
in config.h :
i) #undef INITIALIZATION_BY___INIT
------------------------------------
Initialisation is done at compile time. This is fast and costs
no extra code in the program.
Allowed expressions currently include integer literals,
string literals, integer operators, string addition, bracketing,
array constructors, the empty mapping and order_alist().
When an object with initialised variables is cloned or inherited,
all initialised variables are copied from the blueprint.
A special application of this feature is to have an initialised
non-empty array or a mapping; it will be shared by all clones or
inheriting objects unless an assignment to the variable -
as opposed to an assignment to an element of the array/mapping -
is done in all clones etc.
To prevent unauthorised changes in initialised arrays/mappings,
you can declare the variables as private or use
a nomask reset/create that checks for undesired inheritance.
ii) #define INITIALIZATION_BY___INIT
-------------------------------------
Creates a function names __INIT() from all variable
initialisations and from calls to __INIT() in all inherited
objects, and runs this function at object creation time.
Any efun can be used in the expressions for variable
initialisations, even ones with severe side effects, like
destruct() or shutdown(). The code created for __INIT() is
a little worse than a medium-skilled lpc-programmer would
generate, because it is scattered all over the program.